package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import easier.window.MatchParentDialogFragment;

public class MainActivity106 extends AppCompatActivity {

    private Button top;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity106.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main106 );
        initView();
    }

    private void initView() {

        top = findViewById( R.id.top );
        top.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                MatchParentDialogFragment fragment = new MatchParentDialogFragment();
                View view = LayoutInflater.from( v.getContext() ).inflate( R.layout.activity_main106_item, null );
                view.findViewById( R.id.cancel ).setOnClickListener( new OnClickListener() {
                    @Override
                    public void onClick( View v ) {

                        fragment.dismiss();
                    }
                } );
                fragment.setDialogView( view );
                fragment.setCancelable( false );
                fragment.show( getSupportFragmentManager(), "full" );
            }
        } );
    }
}